//
//  CMMyShareCtrl.m
//  CreditManger
//
//  Created by chaiyanan on 15/11/2.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "CMMyShareCtrl.h"
#import "CMGetAppUrlInfo.h"
#import "CMGetAppUrlParam.h"
#import "CMGetAppUrlParser.h"
#import "UIImage+QRCode.h"

@interface CMMyShareCtrl ()

@property (nonatomic, strong) CMGetAppUrlInfo *appInfo;
@property (nonatomic, weak) IBOutlet UIImageView *appImageView;

@end

@implementation CMMyShareCtrl

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self requestToGetAppUrl];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

#pragma mark - net method

- (void)requestToGetAppUrl
{
    CMGetAppUrlParam *param = [[CMGetAppUrlParam alloc]init];
    CMGetAppUrlParser *parser = [[CMGetAppUrlParser alloc]init];
    [NetCenter getDataFromURL:Method_getAppUrl params:param parser:parser result:^(ParserResult *myResult) {
        
        
        if (myResult.code == 0)
        {
            CMGetAppUrlInfo *info = (CMGetAppUrlInfo *)myResult.result;
            self.appInfo = info;
            [self.appImageView setImage:[UIImage QRCodeWithString:self.appInfo.dataInfo]];
            DISSMISS_SUC(myResult.message);
        }
        else
        {
            DISSMISS_ERR(myResult.message);
        }

        
    } failure:^(NSError *error) {
        DISSMISS_ERR([error description]);
    }];
}

@end
